```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MyBatis动态SQL深度解析 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #f8f9fa;
            border-left: 4px solid #6e8efb;
        }
        .tag-highlight {
            color: #d63384;
            font-weight: 500;
        }
        .hover-scale {
            transition: transform 0.3s ease;
        }
        .hover-scale:hover {
            transform: translateY(-5px);
        }
        .section-divider {
            border-top: 1px solid #e5e7eb;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl text-center">
            <div class="inline-block bg-white bg-opacity-20 rounded-full px-4 py-2 mb-4">
                <span class="text-sm font-medium">高级技术解析</span>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-6">MyBatis动态SQL深度解析</h1>
            <p class="text-xl opacity-90 max-w-2xl mx-auto mb-8">掌握动态SQL的艺术，构建灵活高效的数据库访问层</p>
            <div class="flex justify-center space-x-4">
                <a href="#intro" class="bg-white text-indigo-600 hover:bg-indigo-50 px-6 py-3 rounded-lg font-medium transition-colors">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#examples" class="bg-white bg-opacity-20 hover:bg-opacity-30 px-6 py-3 rounded-lg font-medium transition-colors">
                    <i class="fas fa-code mr-2"></i>代码示例
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-4xl px-4 md:px-0 py-12">
        <!-- Introduction Section -->
        <section id="intro" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-2xl font-bold text-gray-800">动态SQL的魅力</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">
                MyBatis的动态SQL是一种强大的机制，可以根据不同的条件生成不同的SQL语句，其中的动态标签包括<code class="tag-highlight">&lt;if&gt;</code>, <code class="tag-highlight">&lt;choose&gt;</code>, <code class="tag-highlight">&lt;when&gt;</code>, <code class="tag-highlight">&lt;otherwise&gt;</code>, <code class="tag-highlight">&lt;trim&gt;</code>, <code class="tag-highlight">&lt;where&gt;</code>, <code class="tag-highlight">&lt;set&gt;</code>, <code class="tag-highlight">&lt;foreach&gt;</code>等，使得在实际开发中可以更灵活地构建SQL语句。
            </p>
            <p class="text-lg text-gray-700">
                当需要在实际开发中处理公共字段时，可以使用动态标签结合MyBatis的参数和OGNL表达式来处理。下面我们将通过几个典型的应用场景，展示动态SQL的强大功能。
            </p>
        </section>

        <!-- Concept Map -->
        <section class="mb-16 bg-white rounded-xl shadow-md p-6 hover-scale">
            <div class="flex items-center mb-6">
                <div class="w-12 h-1 bg-purple-500 mr-4"></div>
                <h2 class="text-2xl font-bold text-gray-800">动态SQL核心概念</h2>
            </div>
            <div class="mermaid">
                graph TD
                    A[动态SQL] --> B[条件判断]
                    A --> C[循环处理]
                    A --> D[结果处理]
                    B --> B1[if标签]
                    B --> B2[choose/when/otherwise]
                    C --> C1[foreach标签]
                    D --> D1[where标签]
                    D --> D2[set标签]
                    D --> D3[trim标签]
            </div>
        </section>

        <!-- Examples Section -->
        <section id="examples">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-2xl font-bold text-gray-800">实际应用示例</h2>
            </div>

            <!-- Example 1 -->
            <div class="mb-12 bg-white rounded-xl shadow-md overflow-hidden hover-scale">
                <div class="bg-gray-800 text-white px-6 py-4 flex items-center">
                    <i class="fas fa-code text-blue-300 mr-3"></i>
                    <h3 class="text-xl font-semibold">使用<code class="ml-1 px-2 py-1 bg-gray-700 rounded">if</code>标签处理公共字段</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-4">根据条件判断是否添加字段，<code>update_time</code>是一个公共字段，当该字段不为空时，会将<code>update_time=#{updateTime}</code>添加到SQL语句中。</p>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto text-sm mb-4"><code class="language-xml">&lt;update id="updateUser" parameterType="User"&gt;
    UPDATE user
    &lt;set&gt;
        &lt;if test="username != null"&gt;username=#{username},&lt;/if&gt;
        &lt;if test="password != null"&gt;password=#{password},&lt;/if&gt;
        &lt;if test="email != null"&gt;email=#{email},&lt;/if&gt;
        &lt;!-- 公共字段的处理 --&gt;
        &lt;if test="updateTime != null"&gt;update_time=#{updateTime},&lt;/if&gt;
    &lt;/set&gt;
    WHERE id=#{id}
&lt;/update&gt;</code></pre>
                    <div class="flex items-center text-sm text-gray-500">
                        <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                        <span>提示：<code>&lt;set&gt;</code>标签会自动去除末尾多余的逗号，简化SQL拼接逻辑。</span>
                    </div>
                </div>
            </div>

            <!-- Example 2 -->
            <div class="mb-12 bg-white rounded-xl shadow-md overflow-hidden hover-scale">
                <div class="bg-gray-800 text-white px-6 py-4 flex items-center">
                    <i class="fas fa-code text-purple-300 mr-3"></i>
                    <h3 class="text-xl font-semibold">使用<code class="ml-1 px-2 py-1 bg-gray-700 rounded">trim</code>标签处理公共字段</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-4"><code>&lt;trim&gt;</code>标签可以用于去除末尾多余的逗号，这在处理动态SQL时特别有用。</p>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto text-sm mb-4"><code class="language-xml">&lt;update id="updateUser" parameterType="User"&gt;
    UPDATE user
    &lt;set&gt;
        &lt;trim suffixOverrides=","&gt;
            &lt;if test="username != null"&gt;username=#{username},&lt;/if&gt;
            &lt;if test="password != null"&gt;password=#{password},&lt;/if&gt;
            &lt;if test="email != null"&gt;email=#{email},&lt;/if&gt;
            &lt;!-- 公共字段的处理 --&gt;
            &lt;if test="updateTime != null"&gt;update_time=#{updateTime},&lt;/if&gt;
        &lt;/trim&gt;
    &lt;/set&gt;
    WHERE id=#{id}
&lt;/update&gt;</code></pre>
                    <div class="bg-blue-50 border-l-4 border-blue-400 p-4">
                        <h4 class="font-medium text-blue-800 mb-2">技术要点：</h4>
                        <ul class="list-disc pl-5 text-blue-700 space-y-1">
                            <li><code>suffixOverrides</code>属性指定需要去除的后缀字符</li>
                            <li>可以配合<code>prefix</code>和<code>prefixOverrides</code>实现更灵活的字符串处理</li>
                            <li>相比纯<code>&lt;set&gt;</code>标签提供更精细的控制</li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- Example 3 -->
            <div class="mb-12 bg-white rounded-xl shadow-md overflow-hidden hover-scale">
                <div class="bg-gray-800 text-white px-6 py-4 flex items-center">
                    <i class="fas fa-code text-green-300 mr-3"></i>
                    <h3 class="text-xl font-semibold">使用OGNL表达式处理公共字段的默认值</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-4">使用OGNL表达式<code>new java.util.Date()</code>为<code>updateTime</code>提供默认值。</p>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto text-sm mb-4"><code class="language-xml">&lt;insert id="insertUser" parameterType="User"&gt;
    INSERT INTO user(username, password, email, create_time, update_time)
    VALUES(#{username}, #{password}, #{email}, 
          #{createTime, jdbcType=TIMESTAMP}, 
          #{updateTime, jdbcType=TIMESTAMP, javaType=java.util.Date, ognl='new java.util.Date()'})
&lt;/insert&gt;</code></pre>
                    <div class="flex items-start p-4 bg-green-50 rounded-lg">
                        <i class="fas fa-info-circle text-green-500 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-medium text-green-800 mb-1">OGNL表达式使用技巧</h4>
                            <p class="text-green-700 text-sm">OGNL(Object-Graph Navigation Language)是MyBatis中强大的表达式语言，可以实现方法调用、属性访问、算术运算等复杂操作。合理使用OGNL可以简化许多配置。</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Example 4 -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden hover-scale">
                <div class="bg-gray-800 text-white px-6 py-4 flex items-center">
                    <i class="fas fa-code text-red-300 mr-3"></i>
                    <h3 class="text-xl font-semibold">使用<code class="ml-1 px-2 py-1 bg-gray-700 rounded">where</code>标签处理动态的WHERE子句</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-4"><code>&lt;where&gt;</code>标签可以动态生成WHERE子句，省略了WHERE关键字，只有在至少一个条件成立的情况下才会添加WHERE。</p>
                    <pre class="code-block p-4 rounded-lg overflow-x-auto text-sm mb-4"><code class="language-xml">&lt;select id="getUserList" parameterType="User" resultType="User"&gt;
    SELECT * FROM user
    &lt;where&gt;
        &lt;if test="username != null"&gt; AND username=#{username}&lt;/if&gt;
        &lt;if test="password != null"&gt; AND password=#{password}&lt;/if&gt;
        &lt;!-- 公共字段的处理 --&gt;
        &lt;if test="updateTime != null"&gt; AND update_time=#{updateTime}&lt;/if&gt;
    &lt;/where&gt;
&lt;/select&gt;</code></pre>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div class="bg-red-50 border-l-4 border-red-400 p-4">
                            <h4 class="font-medium text-red-800 mb-2">注意事项：</h4>
                            <ul class="list-disc pl-5 text-red-700 space-y-1 text-sm">
                                <li>条件语句前的"AND"是必须的，<code>&lt;where&gt;</code>会自动处理</li>
                                <li>如果所有条件都不满足，WHERE子句不会生成</li>
                                <li>可以避免WHERE后直接跟AND/OR导致的语法错误</li>
                            </ul>
                        </div>
                        <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4">
                            <h4 class="font-medium text-yellow-800 mb-2">最佳实践：</h4>
                            <ul class="list-disc pl-5 text-yellow-700 space-y-1 text-sm">
                                <li>复杂的条件逻辑优先使用<code>&lt;where&gt;</code>而非手动拼接</li>
                                <li>结合<code>&lt;if&gt;</code>实现灵活的条件过滤</li>
                                <li>可以通过<code>&lt;bind&gt;</code>预处理参数简化条件表达式</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mt-16 pt-8 border-t border-gray-200">
            <div class="bg-indigo-50 rounded-xl p-6">
                <h2 class="text-xl font-bold text-indigo-800 mb-4 flex items-center">
                    <i class="fas fa-star text-indigo-500 mr-3"></i>关键总结
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-indigo-500 mb-2">
                            <i class="fas fa-check-circle text-xl"></i>
                        </div>
                        <h3 class="font-medium text-gray-800 mb-2">灵活性</h3>
                        <p class="text-gray-600 text-sm">动态SQL标签让SQL语句能够根据参数条件灵活变化，满足各种复杂业务场景。</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-indigo-500 mb-2">
                            <i class="fas fa-broom text-xl"></i>
                        </div>
                        <h3 class="font-medium text-gray-800 mb-2">简洁性</h3>
                        <p class="text-gray-600 text-sm">通过<code>&lt;where&gt;</code>、<code>&lt;set&gt;</code>等标签自动处理语法细节，减少冗余代码。</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-indigo-500 mb-2">
                            <i class="fas fa-magic text-xl"></i>
                        </div>
                        <h3 class="font-medium text-gray-800 mb-2">强大功能</h3>
                        <p class="text-gray-600 text-sm">结合OGNL表达式可以实现默认值设置、方法调用等高级功能。</p>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto max-w-4xl px-4 md:px-0">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-medium text-white mb-2">技术小馆</h3>
                    <p class="text-sm">专注分享前沿技术知识与实践经验</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition-colors flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>访问语雀主页</span>
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-6 border-t border-gray-800 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```